using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimationSpeedController:StateMachineBehaviour {
	public override void OnStateEnter(Animator animator,AnimatorStateInfo stateInfo,int layerIndex) {
		
		if(animator.GetBool("useTime")) {
			animator.SetBool("useTime",false);

			float time = animator.GetFloat("time");		
			bool isTimeMaxTime = animator.GetBool("isTimeMaxTime");
			float baseTime = stateInfo.length*animator.speed;

			if(isTimeMaxTime&&time>baseTime) time=baseTime;
			if(time<=0) animator.speed=1;
			else animator.speed=baseTime/time;

		}else animator.speed=1;
	}
}
